package com.jvyou.jdbc;

import com.zaxxer.hikari.HikariDataSource;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/18 9:51
 * @Description
 */
public class HikariCPExample {

    public static void main(String[] args) throws SQLException {
        // 1. 创建数据源
        HikariDataSource dataSource = new HikariDataSource();
        // 2. 配置参数
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/jvyou-mybatis");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");
        // 3.获取连接
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
        // 4. 归还连接
        connection.close();
        dataSource.close();
    }
}
